﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lion.WeiXin.Core.Models
{
    /// <summary>
    /// 微信用户
    /// </summary>
   public class WeChatUserModel:BaseModel
    {
       public string OpenId { get; set; }

       public string NickName { get; set; }

       public string HeadPicture { get; set; }
       /// <summary>
       /// 微信用户分组ID ，关联Dictionary
       /// </summary>
       public int Dic_UserGroup { get; set; }

       /// <summary>
       /// 用户分组名
       /// </summary>
       public string UserGroupName { get; set; }

       /// <summary>
       /// 绑定的VIP卡号 
       /// </summary>
       public string VipCardCode { get; set; }

       /// <summary>
       /// 性别： 男1，女 0
       /// </summary>
       public int Sex { get; set; }

       /// <summary>
       /// 是否订阅公众号
       /// </summary>
       public int IsSubscribe
       {
           get;
           set;
       }

       /// <summary>
       /// 订阅时间
       /// </summary>
       public DateTime Subscribe_Date
       {
           get;
           set;
       }

       /// <summary>
       /// 所在城市
       /// </summary>
       public string City
       {
           get;
           set;
       }

       /// <summary>
       /// 所在省
       /// </summary>
       public string Province
       {
           get;
           set;
       }

       /// <summary>
       /// 所在国家
       /// </summary>
       public string Country
       {
           get;
           set;
       }

       public DateTime ConvertIntToDate(long totalSeconds)
       {
           System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
           return startTime.AddSeconds(totalSeconds);
       }

       /// <summary>
       /// 返回时间整数，起始时间为1970-1-1 00:00:00:0000
       /// </summary>
       /// <param name="time"></param>
       /// <returns></returns>
       public long ConvertDateToInt(System.DateTime time)
       {
           System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
           return (long)(time - startTime).TotalSeconds;
       }
    }
}
